<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>加减乘除</title>
	</head>
	<body>
		<p>数字1：</p>
		<input id="n1" type="text"/>
		<p>数字2：</p>
		<input id="n2" type="text"/>
		<input id "sum" type="button" value="加" onclick="add()" />
		<input id "sum" type="button" value="乘" onclick="ride()" />
		<input id "sum" type="button" value="除" onclick="except()" />
		<input id "sum" type="button" value="减" onclick="reduce()" />
		<p id="sum"></p>
		<script>
			function add(){
				var num1=document.getElementById('n1');
				var num2=document.getElementById('n2');
				var sum=document.getElementById('sum');
				var result=num1.value+num2.value;
					result=Number(num1.value)+Number(num2.value);
					sum.innerHTML=(num1.value)+"+"+(num2.value+"="+result);
			}
			function ride(){
				var num1=document.getElementById('n1');
				var num2=document.getElementById('n2');
				var sum=document.getElementById('sum');
				var result=num1.value*num2.value;
					result=Number(num1.value)*Number(num2.value);
					sum.innerHTML=(num1.value)+"*"+(num2.value+"="+result);
			}
			function except(){
				var num1=document.getElementById('n1');
				var num2=document.getElementById('n2');
				var sum=document.getElementById('sum');
				var result=num1.value/num2.value;
					result=Number(num1.value)/Number(num2.value);
					if(isNaN(num1,value)){
					alert("第一个数字不合法是非数字型")
				}else if()isNaN(num2.value){
					alert("第二个数字不合法是非数字型")
				}else{
					sum.innerHTML=(num1.value)+"+"+(num2.value+"="+result);
				}
			}
			function reduce(){
				var num1=document.getElementById('n1');
				var num2=document.getElementById('n2');
				var sum=document.getElementById('sum');
				var result=num1.value-num2.value;
					result=Number(num1.value)-Number(num2.value);
			     sum.innerHTML=(num1.value)+"+"+(num2.value+"="+result);
			
			
		</script>
	</body>
</html>
